FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci  # 安装所有依赖，包括开发依赖
COPY . .
RUN npm run build

# 生产阶段 - 使用nginx提供静态文件服务
FROM nginx:alpine AS production

# 复制自定义nginx配置
COPY nginx.conf /etc/nginx/nginx.conf

# 从构建阶段复制构建好的文件到nginx目录
COPY --from=builder /app/dist /usr/share/nginx/html

# 暴露端口
EXPOSE 80


# 启动nginx
CMD ["nginx", "-g", "daemon off;"]
